From 1ffde104dec2c8bb83e76735724c7da79c617829 Mon Sep 17 00:00:00 2001 From: parkrrrr Date: Thu, 22 Jul 2004 00:15:55 +0000 Subject: [PATCH] Add human-readable testo case (and fix bugs) --- gpsbabel/csv_util.c | 40 ++++++++++++++++++----------- gpsbabel/reference/human.in | 7 +++++ gpsbabel/reference/humanread.out | 6 +++++ gpsbabel/reference/humanread.style | 20 +++++++++++++++ gpsbabel/reference/humanwrite.out | 6 +++++ gpsbabel/reference/humanwrite.style | 28 ++++++++++++++++++++ gpsbabel/testo | 32 ++++++++++++++++++++++- 7 files changed, 123 insertions(+), 16 deletions(-) create mode 100644 gpsbabel/reference/human.in create mode 100644 gpsbabel/reference/humanread.out create mode 100644 gpsbabel/reference/humanread.style create mode 100644 gpsbabel/reference/humanwrite.out create mode 100644 gpsbabel/reference/humanwrite.style diff --git a/gpsbabel/csv_util.c b/gpsbabel/csv_util.c index 6d2638633..861b8f267 100644 --- a/gpsbabel/csv_util.c +++ b/gpsbabel/csv_util.c @@ -337,14 +337,19 @@ human_to_dec( const char *instr, double *outlat, double *outlon ) while ( cur && *cur ) { switch (*cur) { case 'n': case 's': case 'N': case 'S': - if ( numind && numind < 3 ) { - numind = 0; + if ( unk[0] != 999 ) { + numind = 0; + numres = unk; + lat[0] = unk[0]; + lat[1] = unk[1]; + lat[2] = unk[2]; + unk[0] = unk[1] = unk[2] = 999; + } + else { + numres = lat; + numind = 0; + lat[0] = lat[1] = lat[2] = 999; } - lat[0] = unk[0]; - lat[1] = unk[1]; - lat[2] = unk[2]; - - numres = lat; if ( *cur == 'n' || *cur == 'N' ) latsign = 1; @@ -353,14 +358,19 @@ human_to_dec( const char *instr, double *outlat, double *outlon ) cur++; break; case 'w': case 'e': case 'W': case 'E': - if ( numind && numind < 3 ) { - numind = 0; + if ( unk[0] != 999 ) { + numind = 0; + numres = unk; + lon[0] = unk[0]; + lon[1] = unk[1]; + lon[2] = unk[2]; + unk[0] = unk[1] = unk[2] = 999; + } + else { + numres = lon; + numind = 0; + lon[0] = lon[1] = lon[2] = 999; } - lon[0] = unk[0]; - lon[1] = unk[1]; - lon[2] = unk[2]; - - numres = lon; if ( *cur == 'e' || *cur == 'E' ) lonsign = 1; @@ -473,7 +483,7 @@ dec_to_human( char *buff, const char *format, const char *dirs, double val ) sprintf( buff+strlen(buff), subformat ); } formatptr += strlen(subformat); - } // end while; + } xfree(subformat); } diff --git a/gpsbabel/reference/human.in b/gpsbabel/reference/human.in new file mode 100644 index 000000000..1d6653764 --- /dev/null +++ b/gpsbabel/reference/human.in @@ -0,0 +1,7 @@ +W 5 10 15 20 25 30 N +1°23'45.678"S 1°23'45.678"E +12d 34.567m N 76d 54.321m E +N 12.345 W 67.890 +12.345N 67.890W +12.345N W67.890 + diff --git a/gpsbabel/reference/humanread.out b/gpsbabel/reference/humanread.out new file mode 100644 index 000000000..50093bff1 --- /dev/null +++ b/gpsbabel/reference/humanread.out @@ -0,0 +1,6 @@ +20.42500 -5.17083 +-1.39602 01.39602 +12.57612 76.90535 +12.34500 -67.89000 +12.34500 -67.89000 +12.34500 -67.89000 diff --git a/gpsbabel/reference/humanread.style b/gpsbabel/reference/humanread.style new file mode 100644 index 000000000..28b50c54e --- /dev/null +++ b/gpsbabel/reference/humanread.style @@ -0,0 +1,20 @@ +# gpsbabel XCSV style file +# +# Format: Human readable read test style +# Author: Ron Parker +# Date: 21 July 2004 +# + +DESCRIPTION Human readable read test style +EXTENSION txt + +# +# FILE LAYOUT DEFINITIIONS: +# +FIELD_DELIMITER TAB +RECORD_DELIMITER NEWLINE + +# +# INDIVIDUAL DATA FIELDS, IN ORDER OF APPEARANCE: +# +IFIELD LATLON_HUMAN_READABLE, "", "" diff --git a/gpsbabel/reference/humanwrite.out b/gpsbabel/reference/humanwrite.out new file mode 100644 index 000000000..8d47faba0 --- /dev/null +++ b/gpsbabel/reference/humanwrite.out @@ -0,0 +1,6 @@ +N 20.425000 W 5.170833 N 020° 25.500' W 005° 10.250' 20.425000 N 5.170833 W N 20.425000 W 5.170833 N 20 25 30.000000 W 5 10 15.000000 N 20 25 30 W 5 10 15 N 20 W 5 20 degrees 5 degrees +S 1.396022 E 1.396022 S 001° 23.761' E 001° 23.761' 1.396022 S 1.396022 E S 1.396022 E 1.396022 S 1 23 45.678000 E 1 23 45.678000 S 1 23 45 E 1 23 45 S 1 E 1 1 degrees 1 degrees +N 12.576117 E 76.905350 N 012° 34.567' E 076° 54.321' 12.576117 N 76.905350 E N 12.576117 E 76.905350 N 12 34 34.020000 E 76 54 19.260000 N 12 34 34 E 76 54 19 N 12 E 76 12 degrees 76 degrees +N 12.345000 W 67.890000 N 012° 20.700' W 067° 53.400' 12.345000 N 67.890000 W N 12.345000 W 67.890000 N 12 20 42.000000 W 67 53 24.000000 N 12 20 42 W 67 53 24 N 12 W 67 12 degrees 67 degrees +N 12.345000 W 67.890000 N 012° 20.700' W 067° 53.400' 12.345000 N 67.890000 W N 12.345000 W 67.890000 N 12 20 42.000000 W 67 53 24.000000 N 12 20 42 W 67 53 24 N 12 W 67 12 degrees 67 degrees +N 12.345000 W 67.890000 N 012° 20.700' W 067° 53.400' 12.345000 N 67.890000 W N 12.345000 W 67.890000 N 12 20 42.000000 W 67 53 24.000000 N 12 20 42 W 67 53 24 N 12 W 67 12 degrees 67 degrees diff --git a/gpsbabel/reference/humanwrite.style b/gpsbabel/reference/humanwrite.style new file mode 100644 index 000000000..04bf783ef --- /dev/null +++ b/gpsbabel/reference/humanwrite.style @@ -0,0 +1,28 @@ +# gpsbabel XCSV style file +# +# Format: Human readable write test style +# Author: Ron Parker +# Date: 21 July 2004 +# + +DESCRIPTION Human readable write test style +EXTENSION txt + +# +# FILE LAYOUT DEFINITIIONS: +# +FIELD_DELIMITER TAB +RECORD_DELIMITER NEWLINE + +# +# INDIVIDUAL DATA FIELDS, IN ORDER OF APPEARANCE: +# +IFIELD LATLON_HUMAN_READABLE, "", "%c %f" +IFIELD LATLON_HUMAN_READABLE, "", "%c %.3d° %6.3f'" +IFIELD LATLON_HUMAN_READABLE, "", "%f %c" +IFIELD LATLON_HUMAN_READABLE, "", "%c %f" +IFIELD LATLON_HUMAN_READABLE, "", "%c %d %d %f" +IFIELD LATLON_HUMAN_READABLE, "", "%c %d %d %d" +IFIELD LATLON_HUMAN_READABLE, "", "%c %d" +IFIELD LATLON_HUMAN_READABLE, "", "%d degrees" + diff --git a/gpsbabel/testo b/gpsbabel/testo index c5dfc4ff8..ded25c418 100755 --- a/gpsbabel/testo +++ b/gpsbabel/testo @@ -3,11 +3,24 @@ export GPSBABEL_FREEZE_TIME PNAME=${PNAME:-./gpsbabel} DIFF=${DIFF:-diff} +OD=${OD:-od -Ax -txC -v} TMPDIR=/tmp/gpsbabel.$$ mkdir -p $TMPDIR trap "rm -fr $TMPDIR" 0 1 2 3 15 +bincompare() +{ + rm -f ${TMPDIR}/bc1 + rm -f ${TMPDIR}/bc2 + ${OD} $1 >${TMPDIR}/bc1 + ${OD} $2 >${TMPDIR}/bc2 + ${DIFF} ${TMPDIR}/bc1 ${TMPDIR}/bc2 || { + echo ERROR binary comparing $* + exit 1 + } +} + compare() { ${DIFF} $* || { @@ -162,6 +175,12 @@ ${PNAME} -i magnav -f reference/magnav.pdb -o gpsutil -F ${TMPDIR}/magnavt.gpu compare ${TMPDIR}/magnavt.gpu ${TMPDIR}/magnav.gpu compare reference/gu.wpt ${TMPDIR}/magnav.gpu +rm -f ${TMPDIR}/magnav.pdb +${PNAME} -i geo -f geocaching.loc -o magnav -F ${TMPDIR}/magnav.pdb +bincompare ${TMPDIR}/magnav.pdb reference/magnav.pdb + + + # GPSPilot Tracker for PalmOS # This test is eerily similar to the NAV Companion test. In fact, the # converted reference file (magnavr.gpu) is identical. @@ -501,6 +520,17 @@ ${DIFF} ${TMPDIR}/gpl1.gpx ${TMPDIR}/gpl2.gpx # rm -f ${TMPDIR}/netstumbler.mps ${PNAME} -i netstumbler -f reference/netstumbler.txt -o mapsource -F ${TMPDIR}/netstumbler.mps -compare ${TMPDIR}/netstumbler.mps reference/netstumbler.mps +bincompare ${TMPDIR}/netstumbler.mps reference/netstumbler.mps + +# +# XCSV "human readable" tests +# +rm -f ${TMPDIR}/humanread.out +${PNAME} -i xcsv,style=reference/humanread.style -f reference/human.in -o arc -F ${TMPDIR}/humanread.out +compare ${TMPDIR}/humanread.out reference/humanread.out + +rm -f ${TMPDIR}/humanwrite.out +${PNAME} -i xcsv,style=reference/humanread.style -f reference/human.in -o xcsv,style=reference/humanwrite.style -F ${TMPDIR}/humanwrite.out +compare ${TMPDIR}/humanwrite.out reference/humanwrite.out exit 0 -- 2.30.2